package com.discover.zookeeper;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Discover
 * Date: 12/2 0002
 * Time: 15:31
 */
public class Master implements Watcher {

    private final static Logger LOGGER = LoggerFactory.getLogger(Master.class);

    private String host;

    public Master(String host){
        this.host = host;
    }

    public void process(WatchedEvent event) {
        LOGGER.info("receive watched event:{}", event.getType().name());
    }

    public void start() throws IOException {
        new ZooKeeper(host, 15000, this);
    }
}
